package com.baizhi.service.impl;

import com.baizhi.dao.ProductDao;
import com.baizhi.entity.Product;
import com.baizhi.service.ProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao pd;


    @Override
    public PageInfo<Product> selectByPage(int page, int limit) {
        PageHelper.startPage(page,limit);
        List<Product> products = pd.selectList(null);
        return new PageInfo<>(products);
    }

    @Override
    public void delete(int id) {
         pd.deleteById(id);
    }

    @Override
    public void addImg(Product p) {
        pd.insert(p);
    }
}
